<!DOCTYPE html>
<html class="x-admin-sm">

<head>
    <meta charset="UTF-8">
    <title>修改赛事</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
        content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
    <link rel="stylesheet" href="../css/font.css">
    <link rel="stylesheet" href="../css/xadmin.css">
    <script type="text/javascript" src="../lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="../js/xadmin.js"></script>
    <script src="../js/base.js"></script>
    <script src="../js/jquery.min.js"></script>
    <script src="../js/gVerify.js"></script>
    <!-- 让IE8/9支持媒体查询，从而兼容栅格 -->
    <!--[if lt IE 9]>
    <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
    <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
    <style>
        .juese {
            text-align: center;
            width: 90%;
            border: 1px solid #ccc;
            margin: 20px auto;
        }

        .juese th {
            text-align: center;
            background: #fff;
        }

        .layui-row .juese .layui-table td,
        .layui-row .juese .layui-table th {
            font-size: 14px;
        }

        .layui-col-md4 label {
            width: 30%;
            padding: 9px 0;
            font-size: 14px;
            color: #999;
        }

        .layui-col-md4 div {
            line-height: 38px;
            width: 70%;
            text-align: left;
            font-size: 14px;
            box-sizing: border-box;
            -webkit-box-sizing: border-box;
            -moz-box-sizing: border-box;
            padding-left: 10px;
        }

        .layui-col-md3 label {
            width: 30%;
            padding: 9px 0;
            font-size: 14px;
            color: #999;
        }

        .layui-col-md3 div {
            line-height: 38px;
            width: 70%;
            text-align: left;
            font-size: 14px;
            box-sizing: border-box;
            -webkit-box-sizing: border-box;
            -moz-box-sizing: border-box;
            padding-left: 10px;
        }

        .layui-col-md5 label {
            width: 30%;
            padding: 9px 0;
            font-size: 14px;
            color: #999;
        }

        .layui-col-md5 div {
            line-height: 38px;
            width: 70%;
            text-align: left;
            font-size: 14px;
            box-sizing: border-box;
            -webkit-box-sizing: border-box;
            -moz-box-sizing: border-box;
            padding-left: 10px;
        }

        .layui-col-md6 label {
            width: 30%;
            padding: 9px 0;
            font-size: 14px;
            color: #999;
        }

        .layui-col-md6 div {
            line-height: 38px;
            width: 70%;
            text-align: left;
            font-size: 14px;
            box-sizing: border-box;
            -webkit-box-sizing: border-box;
            -moz-box-sizing: border-box;
            padding-left: 10px;
        }

        .layui-input-inline {
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
        }

        .layui-table th {
            background-color: #f2f2f2;
        }
    </style>
</head>

<body>
    <div class="layui-fluid">
        <div class="layui-row" style="padding-right: 9%;">
            <form class="layui-form">
                <div class="layui-form-item">
                    <label class="layui-form-label">姓名：</label>
                    <div class="layui-input-block" id="name" style="line-height: 38px;">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">由</label>
                    <div class="layui-input-block" id="you" style="line-height: 38px;">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">转到</label>
                    <div class="layui-input-block">
                        <select name="teamList" id="teamList" lay-verify="required">
                            <option value=""></option>
                        </select>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">球号</label>
                    <div class="layui-input-block">
                        <input oninput="value=value.replace(/[^\d]/g,'')" name="qiuhao" placeholder="请输入球号"
                            autocomplete="off" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item layui-form-text">
                    <label class="layui-form-label">转会原因</label>
                    <div class="layui-input-block">
                        <textarea name="desc" placeholder="请输入内容" class="layui-textarea"></textarea>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">验证码</label>
                    <div class="layui-input-inline" style="width: 100px;">
                        <input style="height: 38px;" type="text" id="code_input" name="yanzhengma" placeholder="请输入验证码"
                            autocomplete="off" class="layui-input">
                    </div>
                    <div class="layui-input-inline" style="height: 38px;width: 100px;" id="v_container">
                    </div>
                </div>
                <div class="layui-form-item" style="text-align: center;">
                    <button class="layui-btn" lay-submit lay-filter="submit">立即提交</button>
                </div>
            </form>
        </div>
    </div>
</body>
<script>
    var verifyCode = new GVerify("v_container");



    layui.use(['form'], function () {
        var form = layui.form;
        // 获取球队列表
        $.ajax({
            url: playerGetTeamList,
            type: 'post',
            data: {},
            dataType: 'json',
            success: function (res) {
                if (res.msg == 0) {
                    for (var i = 0; i < res.teamList.length; i++) {
                        $("#teamList").append("<option value=\"" + res.teamList[i].id + "\">" + res
                            .teamList[i].name + "</option>")
                    }
                    form.render()
                } else {
                    layer.alert(res.msg, {
                        title: '提示'
                    })
                }
            },
            error: function (res) {
                layer.alert(res.msg, {
                    title: '提示'
                })
            }
        });
        form.on('submit(submit)', function (data) {

            var userId = $("#name").attr("data-val");
            var oldTeamId = $("#you").attr("data-val");
            var newTeamId = data.field.teamList;
            var content = data.field.desc;
            var num = data.field.qiuhao;
            if (userId == undefined || userId == "") {
                layer.alert("未获取到用户ID", {
                    title: "提示"
                })
                return false
            } else if (oldTeamId == undefined || oldTeamId == "") {
                layer.alert("未获取到前球队ID", {
                    title: "提示"
                })
                return false
            } else if (newTeamId == undefined || newTeamId == "") {
                layer.alert("请选择转入球队", {
                    title: "提示"
                })
                return false
            } else if (num == undefined || num == "") {
                layer.alert("请输入球号", {
                    title: "提示"
                })
                return false
            } else if (content == undefined || content == "") {
                layer.alert("请输入转会原因", {
                    title: "提示"
                })
                return false
            }
            var res = verifyCode.validate(document.getElementById("code_input").value);
            if (res) {
                // 提交转会信息
                $.ajax({
                    url: transfer,
                    type: 'post',
                    data: {
                        userId: userId,
                        oldTeamId: oldTeamId,
                        newTeamId: newTeamId,
                        content: content,
                        num: num
                    },
                    dataType: 'json',
                    success: function (res) {
                        if (res.msg == 0) {
                            parent.parent.layui.table.reload("testReload");
                            parent.layer.msg('转会成功');
                            var index = parent.layer.getFrameIndex(window
                                .name); //先得到当前iframe层的索引
                            parent.layer.close(index); //再执行关闭   
                        } else {
                            layer.alert(res.msg, {
                                title: '提示'
                            })
                        }
                    },
                    error: function (res) {
                        layer.alert(res.msg, {
                            title: '提示'
                        })
                    }
                });
            } else {
                layer.alert('验证码错误，请重新输入', {
                    title: '提示'
                })
                return false
            }
            return false
        })
    })

    function child(id) {
        valId = id;


    };
</script>

</html>